# 展示 按下了哪个键

import tkinter
import time

from tkinter import *

def sleep_time():
    time.sleep(2)

root = tkinter.Tk()
root.geometry('800x600')


event_char=''
_wait = '---__---__---_--__--__---'
now_time = time.time()

def progress(event):

    while time.time() == now_time+2:
        global event_char
        event_char += _wait
        label['text'] = event_char

button1 = tkinter.Button(root,text = '确定')
button1.bind('<KeyPress>',progress)
button1.focus()
button1.pack()

label = tkinter.Label(root,width = 30,height = 30,bg = 'skyblue')

label.place(x=20,y=20)

root.mainloop()